package com.sdx.console.spread.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;
import com.sdx.common.utils.Utils;
import lombok.Data;
import org.beetl.sql.core.annotatoin.AssignID;
import org.beetl.sql.core.annotatoin.ColumnIgnore;
import org.beetl.sql.core.annotatoin.Table;

import java.util.Date;

/**
 * @ClassName SpreadShare
 * @Description
 * @Author kangbin
 * @Date 2020/3/20 16:04
 */
@Data
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@Table(name = "coredb.promote_record")
public class SpreadChannel extends BaseEntity {


    @ColumnIgnore
    private Integer userId;
    //推广码
    @AssignID
    private String promoteCode ;

    private String promoteName;

    //发起人类型 a、本公司员工，b、区域、c、合作伙伴
    @Dict(type="channel_type")
    private String promoterType ;

    //所属渠道

    private String channelCode ;

    @ColumnIgnore
    private String channelName;

    //所属公司

    private Integer orgId ;

    @ColumnIgnore
    private String orgName;

    //员工id 当发起人类型为本公司员工时有值

    private String customerId ;

    //备注

    private String promoteMemo ;

    //是否可用 1、正常，0、失效

    private String codeStatus ;

    //生成时间

    private Date createdTime ;

    //创建人

    private Integer createdBy ;

    //创建人名称

    private String createdName ;

    //更新时间

    private Date updatedTime ;

    //更新人

    private Integer updatedBy ;

    //更新人名称

    private String updatedName ;

    private Integer tenantId;

    //订单数
    private Long total;

    // 订单总额
    private Long totalMoney;

    private Integer totalStart;
    private Integer totalEnd;

    private Long totalMoneyStart;
    private Long totalMoneyEnd;

    private String createTimeQuery;

    private Date createTimeStart;

    private Date createTimeEnd;
    public String getCreateTimeQuery(){
        return  createTimeQuery;
    }
    public void setCreateTimeQuery(String createTimeQuery ){
        this.createTimeQuery = createTimeQuery;
        Date[] timePair = Utils.parseQueryTime(createTimeQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.createTimeStart = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.createTimeEnd = timePair[1];
        }
    }

}
